<style>
.l-map{
	width:320px;
	height:320px;
}
</style>
<div id="l-map" class="l-map"></div>
<div id="r-result"></div>
<script type="text/javascript">
var map = new BMap.Map("l-map");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
map.setCenter("北京");

map.enableScrollWheelZoom();
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));

var output = "";
var searchComplete = function (results){
	
	if (driving.getStatus() != BMAP_STATUS_SUCCESS){
        return false;
    }
	var plan   = results.getPlan(0);
    $("#juli1").html(plan.getDistance(true));
    $("#juli2").html(plan.getDistance(true));
}

var p1 = new BMap.Point({$detail.longitude},{$detail.latitude}); //餐厅地址
var p2 = new BMap.Point({$result.pointlng},{$result.pointlat});  //用户地址
var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map,enableDragging : true},//, autoViewport: true
	onSearchComplete: searchComplete,
	onPolylinesSet: function(){
		map.centerAndZoom(new BMap.Point({$result.pointlng},{$result.pointlat}),13);
        //alert(output);
	}
});
driving.search(p1, p2);

/**/

</script>
